/**
 *
 */
package jp.seraph.same.view.cui;

import jp.seraph.cui.AbstractMode;
import jp.seraph.cui.InternalConsole;
import jp.seraph.cui.Mode;
import jp.seraph.cui.SystemNodeType;
import jp.seraph.jsade.model.AngleVelocityCalculator;
import jp.seraph.jsade.model.JointIdentifierContainer;
import jp.seraph.jspf.pose.PoseManager;
import jp.seraph.same.controller.DefaultMotionController;
import jp.seraph.same.controller.MotionController;
import jp.seraph.same.controller.MotionManagerController;
import jp.seraph.same.model.MotionModel;

/**
 *
 *
 */
public class MotionEditMode extends AbstractMode {
    public MotionEditMode(Mode aParent, InternalConsole aConsole, MotionManagerController aController, PoseManager aPoseManager, JointIdentifierContainer aIdContainer, AngleVelocityCalculator aDefaultCalculator){
        super(aParent, aConsole);

        mController = aController;
        mPoseManager = aPoseManager;
        mDefaultCalculator = aDefaultCalculator;
        mIdContainer = aIdContainer;
    }

    private MotionManagerController mController;
    private PoseManager mPoseManager;
    private JointIdentifierContainer mIdContainer;
    private AngleVelocityCalculator mDefaultCalculator;

    /**
     *
     * @see jp.seraph.cui.SystemNode#getName()
     */
    public String getName() {
        return "MotionMode";
    }

    /**
     *
     * @see jp.seraph.cui.SystemNode#getType()
     */
    public SystemNodeType getType() {
        return MotionEditModeType.getInstance();
    }

    /**
     *
     * @see jp.seraph.cui.SystemNode#isRoot()
     */
    public boolean isRoot() {
        return false;
    }

    /**
     *
     * @see jp.seraph.cui.SystemNode#setName(java.lang.String)
     */
    public void setName(String aName) {
        // 何もしない
    }

    public void createMotion(String aMotionName){
        MotionEditMode tParent = this;
        String tMotionName = aMotionName;

        MotionModel tModel = mController.createMotion(tMotionName);
        MotionController tController = new DefaultMotionController(tModel, mController);
        MotionData tNewMotion = new MotionData(tParent, this.getConsole(), tMotionName, tModel, tController, mPoseManager, mIdContainer, mDefaultCalculator);

        tParent.addChild(tNewMotion);
    }
}
